package com.fenqing.leetcode.code.t1400_1500;

import com.fenqing.annotations.DesignClass;
import com.fenqing.core.design.DesignTopic;

public class Topic1476 extends DesignTopic {
    public Topic1476() {
        super(
                "[\"SubrectangleQueries\",\"getValue\",\"updateSubrectangle\",\"getValue\",\"getValue\",\"updateSubrectangle\",\"getValue\",\"getValue\"]",
                "[[[[1,2,1],[4,3,4],[3,2,1],[1,1,1]]],[0,2],[0,0,3,2,5],[0,2],[3,1],[3,0,3,2,10],[3,1],[0,2]]"
        );
    }

    public static void main(String[] args) {
        Topic1476 topic1476 = new Topic1476();
        String run = topic1476.run();
        System.out.println(run);
    }

    @DesignClass
    public static class SubrectangleQueries {

        int[][] rectangle;

        public SubrectangleQueries(int[][] rectangle) {
            this.rectangle = rectangle;
        }

        public void updateSubrectangle(int row1, int col1, int row2, int col2, int newValue) {
            for (int i = row1; i <= row2; i++) {
                for (int j = col1; j <= col2; j++) {
                    this.rectangle[i][j] = newValue;
                }
            }
        }

        public int getValue(int row, int col) {
            return this.rectangle[row][col];
        }
    }

}
